package com.misty.strategy_pattern.client1;

import com.misty.strategy_pattern.client1.strategy_factory.PromotionStrategyFactory;
import org.junit.Test;

public class Client {

    @Test
    public void demo() {
        StrategyContext strategy618 = new StrategyContext(new LiJianPromotionStrategy());
        StrategyContext strategy1111 = new StrategyContext(new FanXianPromotionStrategy());
        StrategyContext strategy1212 = new StrategyContext(new ManJianPromotionStrategy());

        strategy618.executePromotionStrategy();
        strategy1111.executePromotionStrategy();
        strategy1212.executePromotionStrategy();

    }

    /**
     * 避免直接在外部使用策略类，防止代码入侵
     */
    @Test
    public void demo2() {
        String promotionKey = "";

        StrategyContext context = new StrategyContext(PromotionStrategyFactory.getPromotionStrategy(promotionKey));

        context.executePromotionStrategy();

    }
}
